const KoaRouter = require("@koa/router");
const labelController = require("../controller/label.controller");
const { verifyAuthorization } = require("../middleware/login.middleware");
const verifyRequiredParams = require("../middleware/required.middleware");
const verifyResourceExists = require("../middleware/exists.middleware");

const labelRouter = new KoaRouter({ prefix: "/label" });

// 创建标签
labelRouter.post(
    "/create",
    verifyAuthorization,
    verifyRequiredParams({ mode: "json", requiredParamsStringArr: ["name"] }),
    labelController.create
);

// 查询所有标签
labelRouter.get("/list", verifyAuthorization, labelController.list);

// 删除标签
labelRouter.delete(
    "/:labelId",
    verifyAuthorization,
    verifyRequiredParams({ mode: "parameter", requiredParamsStringArr: ["labelId"] }),
    verifyResourceExists,
    labelController.removeLabelById
);
module.exports = labelRouter;
